home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / include / hpointn.h < prev    next >
C/C++ Source or Header  |  1993-07-28  |  3KB  |  85 lines

  1. /* Copyright (c) 1992 The Geometry Center; University of Minnesota
  2.    1300 South Second Street;  Minneapolis, MN  55454, USA;
  3.    
  4. This file is part of geomview/OOGL. geomview/OOGL is free software;
  5. you can redistribute it and/or modify it only under the terms given in
  6. the file COPYING, which you should have received along with this file.
  7. This and other related software may be obtained via anonymous ftp from
  8. geom.umn.edu; email: software@geom.umn.edu. */
  9.  
  10. /* Authors: Charlie Gunn, Pat Hanrahan, Stuart Levy, Tamara Munzner, Mark Phillips */
  11.  
  12. #ifndef HPOINTNDEF
  13. #define HPOINTNDEF
  14.  
  15. #include "reference.h"
  16.  
  17. typedef float HPtNCoord;
  18. typedef struct HPtN {
  19.     short dim;    /* Dimension, including homogeneous divisor */
  20.     short flags;    /* Space tag */
  21.     HPtNCoord *v;    /* Array of coordinates; v[dim-1] is the homogenous divisor */
  22. } HPointN;
  23.  
  24.  
  25. /* N-dimensional transformation matrix.
  26.  * Transforms row vectors (multiplied on the left) of dimension 'idim',
  27.  * yielding row vectors of dimension 'odim'.
  28.  */
  29. typedef struct TmN {
  30.     REFERENCEFIELDS
  31.     short idim, odim;
  32.     short flags;
  33.     HPtNCoord *a;    /* Array of idim rows, odim columns */
  34. } TransformN;
  35.  
  36. #define    TMNMAGIC    OOGLMagic('T', 1)
  37.  
  38. /* Refer to the (i,j)'th entry in a TransformN object;
  39.  * beware that (i,j) are not checked!
  40.  */
  41. #define  TmNentry(T, i,j)  ((T)->a[(i)*(T)->odim + (j)])
  42.  
  43.  
  44.     /* Construct point */
  45. /*skip*/
  46. extern HPointN *HPtNCreate(int dim, const HPtNCoord *vec);
  47.     /* Destroy point */
  48. /*skip*/
  49. extern void HPtNDelete(HPointN *pt);
  50.     /* Copy point */
  51. extern HPointN *HPtNCopy(const HPointN *pt1, HPointN *pt2);
  52.     /* Sum of points */
  53. extern HPointN *HPtNAdd(const HPointN *pt1, const HPointN *pt2, HPointN *sum);
  54.     /* Space */
  55. /*skip*/
  56. extern int HPtNSpace( const HPointN *pt );
  57. /*skip*/
  58. extern HPointN *HPtNSetSpace( HPointN *pt, int space );
  59.  
  60.     /* Linear combination */
  61. extern HPointN *HPtNComb(HPtNCoord u, const HPointN *pu, HPtNCoord v, const HPointN *pv, HPointN *sum);
  62.  
  63.     /* Reduce to unit vector */
  64. extern HPointN *HPtNUnit(const HPointN *from, HPointN *to);
  65.  
  66.     /* Dehomogenize, returning old 'w' component */
  67. extern HPtNCoord HPtNDehomogenize(const HPointN *from, HPointN *to);
  68.  
  69.     /* Apply a TransformN to an HPointN */
  70. extern HPointN *HPtNTransform( const TransformN *T, const HPointN *from, HPointN *to );
  71.  
  72.     /* Add zeros to a vector to make it a given dimension */
  73. extern HPointN *HPtNPad(HPointN *from, int dim, HPointN *to);
  74.  
  75.     /* Dot product of two vectors */
  76. extern HPtNCoord HPtNDot( const HPointN *p1, const HPointN *p2);
  77.  
  78.     /* Return index'th component of p . T */
  79.     /* If index is out of range (e.g. -1), return N-1'th component
  80.      * (i.e. homogeneous divisor).
  81.      */
  82. extern HPtNCoord *HPtNTransformComponent( const HPointN *p, const TransformN *T, int ncomponents, int *indices, HPtNCoord *results );
  83.  
  84. #endif
  85.